<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .bg{
            width:100px;
            height: 200px;
            background: red;
        }
        .bg2{
            width: 200px;
            height: 300px;
            background: green;
        }
    </style>
</head>
<body>
    <button>更改</button>
    <div class="bg"></div>
</body>
<script>
    document.querySelector("button").onclick = function(){
        // console.log(document.querySelector("div").className);
        document.querySelector("div").className = "bg2"
    }
</script>
</html>